 /*
      cron 一天10次 


-------------------  青龙-配置文件-复制区域  -------------------

多多故事
https://bp-api.shinet.cn
抓包链接的oaid 请求里的accesskey


export ddgsck=" oaid # accesskey"

-------------------代理配置--------------------
export dldz=''
-------------------需要账号失效通知就设置-------------------
WxPusher官网: https://wxpusher.zjiecode.com/admin/main/app/appInfo
后台新建应用，获取appToken   微信扫描关注后在公众号获取uuid

export appToken='apptoken#uid'


*/
let tixiandian =9//提现时间
NAME = `多多故事`; VALY = ['ddgsck']

CK=``
let appToken = process.env.weixinToken
let dldz = process.env.dldz//
let host = 'https://bp-api.shinet.cn'
const Vacation = '1.1'
const CryptoJS = require('crypto-js')
const NodeRSA = require('node-rsa');
const envSplitor = ['\n', '@'] //支持多种分割
const LOGS =0//1开日志。0关闭
usid = 0
class Bar {
    constructor(str) {
        this.oaid = str.split('#')[0]
        this.accesskey = str.split('#')[1]
        this.timeee = this.accesskey.slice(-10);
        this.num = ++usid
        this.headers = {
            'User-Agent': 'Mozilla/5.0 (Linux; Android 9; PCLM10 Build/PQ3A.190605.10171107; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Mobile Safari/537.36',
           // 'Accept-Encoding': 'gzip',
            'appversion': '1.0.1',
            'os': 'android',
            'romversion': 'default',
            'channel': 'ttznddgs12ddy',
            'gps': '',
          //  'ua': 'Mozilla/5.0 (Linux; Android 9; PCLM10 Build/PQ3A.190605.10171107; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Mobile Safari/537.36',
            'pkg': 'com.hainanyt.ddgs',
           // 'deviceid': '863818020710647',
           // 'mac': '00:db:5d:e0:ac:42',
            'bs': 'default',
            'osversion': '13',
            'accesskey': this.accesskey,
            'appid': '1094',
          //  'imei': '863818020710647',
            'model': 'Pixel XL',
            'pkgid': '796',
            'brand': 'Xiaomi',
            'oaid': this.oaid ,
           // 'androidid': 'c347e47356c18253'
          }
  

    }
    async hqdl() {//获取代理
        let result = await $.task('get', dldz, { 'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36' })
        this.dlip = result.split('\n')[0]
        console.log(`账号${this.num}：代理IP：${this.dlip}`)
    }

    async user_task_list() {
        await $.wait($.RT(1000, 3000));
        this.ming = '开宝箱';
        await this.kaibaoxiang(5);//开宝箱
        this.ming = '阅读';
        await $.wait($.RT(5000, 15000));
        await this.kaibaoxiang(9);//阅读
        await $.wait($.RT(5000, 15000));
        this.ming = '看视频'
        await this.kaibaoxiang(7);//看视频
        await $.wait($.RT(3000, 5000));
        if($.timenow(3) == tixiandian){
          await this.tixian()//提现
        }
    }



    async login() {//用户信息
      let data = await this.task('get',`${host}/shua-ddgs/user/message?appId=1094&pkgId=796`, this.headers)
        if (data.code == 0) {
            this.login = true
            this.num = data.result.userData.nickName
            await this.xinxi()
        } else {
            this.login = false
            let msg=data.message
            console.log(`${this.num}：${msg}`)
            await this.wxpusher(msg)
        }
        
    }
    async xinxi() {//用户信息
        let data = await this.task('get',`${host}/shua-ddgs/main/page?appId=1094&pkgId=796`, this.headers)
          if (data.code == 0) {
            let yue=data.result.gold/100000
              console.log(`${this.num} 余额：${yue.toFixed(2)}元`)
          } else {
              console.log(`${this.num} ${data.message}`)
          }
          
      }

    async wxpusher(id) {//wxpusher微信通知
        let headers = {
            "X-Requested-With": "com.tencent.mm",
            "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 13; M2012K11AC Build/TKQ1.220829.002)",
        }
        let data = await this.task('get', `https://wxpusher.zjiecode.com/api/send/message/?appToken=${appToken.split('#')[0]}&content=${encodeURI(`${NAME}${id}`)}&uid=${appToken.split('#')[1]}`, headers)
        if (data.code == 1000) {
            console.log(`微信通知${data.msg}`)
        } else { console.log(`微信通知失败`) }

    }

    async kaibaoxiang(id){//开宝箱
        let sign = $.RSA(`${this.timeee}-${$.time(13)}-${$.RT(100, 160)}`, 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIvrbMM3mHUceVQlJwTwsZIvBmA6iN5SuqQu01VSpK8wO7pjVwNi/8N78a2xNcs9VsIId3J0+VUW9CwLWHMWKRECAwEAAQ==')
        this.headers['sign']=sign
        let data = await this.task('get', `${host}/shua-ddgs/look/ad/video?position=${id}&appId=1094&pkgId=796`, this.headers)
          if (data.code == 0) {
             console.log(`${this.num} ${this.ming}：${data.result.gold/100000}元`)
          } else {
              console.log(`${this.num} ${this.ming}:${data.message}`)
          }
      }
      async tixian(){//提现
        let sign = $.RSA(`${this.timeee}-${$.time(13)}-160`, 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIvrbMM3mHUceVQlJwTwsZIvBmA6iN5SuqQu01VSpK8wO7pjVwNi/8N78a2xNcs9VsIId3J0+VUW9CwLWHMWKRECAwEAAQ==')
        this.headers['sign']=sign
        let data = await this.task('get', `${host}/shua-ddgs/gold/withdraw?appId=1094&pkgId=796`, this.headers)
          if (data.code == 0) {
             console.log(`${this.num} 提现：${data.result.cash/100000}元`)
          } else {
              console.log(`${this.num} 提现:${data.message}`)
          }
      }

    async task(method, taskurl, taskheader, taskbody) {//代理请求模块
        if (method == 'delete') {
            method = method.toUpperCase()
        } else {
            method = method
        }
        const request = require('request')
        if (method == 'post') {
            delete taskheader['Content-Type']
            delete taskheader['content-type']
            delete taskheader['Content-Length']
            delete taskheader['content-length']
            if ($.safeGet(taskbody)) {
                taskheader['content-type'] = 'application/json;charset=utf-8'
            } else {
                taskheader['content-type'] = 'application/json'
            }
            if (taskbody) {
                taskheader['content-length'] = $.lengthInUtf8Bytes(taskbody)
            }
        }
        if (method == 'get') {
            delete taskheader['Content-Type']
            delete taskheader['content-length']
            delete taskheader['content-type']
            delete taskheader['Content-Length']
        }
        taskheader['Host'] = taskurl['replace']('//', '/')['split']('/')[1]
        if (dldz == undefined) {
            if (method.indexOf('T') < 0) {
                var httpget = {
                    url: taskurl,
                    headers: taskheader,
                    body: taskbody,
                    // proxy:`http://${this.dlip}`,
                    timeout: 20000
                }
            } else {
                var httpget = {
                    url: taskurl,
                    headers: taskheader,
                    form: JSON.parse(taskbody),
                    // proxy:`http://${this.dlip}`,
                    timeout: 20000
                }
            }
        } else {
            if (method.indexOf('T') < 0) {
                var httpget = {
                    url: taskurl,
                    headers: taskheader,
                    body: taskbody,
                    proxy: `http://${this.dlip}`,
                    timeout: 20000
                }
            } else {
                var httpget = {
                    url: taskurl,
                    headers: taskheader,
                    form: JSON.parse(taskbody),
                    proxy: `http://${this.dlip}`,
                    timeout: 20000
                }
            }
        }
        return new Promise(async resolve => {
            request[method.toLowerCase()](httpget, async (err, response, data) => {
                try {

                    if (LOGS == 1) {
                        console.log(`==================请求==================`)
                        console.log(JSON.stringify(httpget))
                        console.log(`==================返回==================`)
                        
                            console.log(data)
                        
                    }
                } catch (e) {
                } finally {
                    if (!err) {
                        if ($.safeGet(data)) {
                            data = JSON.parse(data)
                        } else {
                            data = data
                        }
                    } else {
                        if (dldz == undefined) {
                            console.log(`请检查网络设置`)
                            data = JSON.parse(`{"code":"99"}`)
                        } else {
                            await this.hqdl()
                            data = await this.task(method, taskurl, taskheader, taskbody)
                        }

                    }
                    return resolve(data)
                }
            })
        })
    }


} $ = DD()
!(async () => {
    console.log(`[${NAME}] ${$.timenow(3)}:${$.timenow(4)}:${$.timenow(5)}`);
    await gpt()


    await $.ExamineCookie()
    if (dldz == undefined) {
        console.log(`当前使用本地网络运行脚本`)
        console.log(`\n-------- 用户信息 --------`)
        await $.Multithreading('login')
        let valid_user_list = $.cookie_list.filter(x => x.login == true)
        if (valid_user_list.length == 0) {
            console.log(`Cookie格式错误 或 账号被禁封`)
            return
        } else {
            console.log(`\n-------- 任务列表 --------`)
            await $.Multithreading('user_task_list')
            console.log(`\n-------- 运行结果 --------`)
        }
        for (let user of $.cookie_list) {
          user.xinxi(0)
        }
    } else {
        console.log(`当前使用代理网络运行脚本`)
        await $.Multithreading('hqdl')
        console.log(`\n-------- 用户信息 --------`)
        await $.Multithreading('login')
        let valid_user_list = $.cookie_list.filter(x => x.login == true)
        if (valid_user_list.length == 0) {
            console.log(`Cookie格式错误 或 账号被禁封`)
            return
        } else {
            console.log(`\n-------- 任务列表 --------`)
            await $.Multithreading('user_task_list')
               console.log(`\n-------- 运行结果 --------`)
        }
      for (let user of $.cookie_list) {

        user.xinxi(0)
      }
    }

})()
    .catch(e => { console.log(e) })
    .finally(() => { })

function DD() {
    return new (class {
        constructor() {
            this.cookie_list = []
            this.message = ''
            this.CryptoJS = require('crypto-js')
            this.NodeRSA = require('node-rsa')
            this.request = require('request')
            this.Sha_Rsa = require('jsrsasign')
        }
        //多线程
        async Multithreading(taskName, id, thread) {
            let workGroup = []
            if (!thread) {
                thread = 1
            }
            while (thread--) {
                for (let user of $.cookie_list) {
                    workGroup.push(user[taskName](id))
                }
            }
            await Promise.allSettled(workGroup)
        }
        //变量检查
        ExamineCookie() {
            let ckStr = process.env[VALY] || CK
            let userCount = 0
            if (ckStr) {
                for (let sp of envSplitor) {
                    if (ckStr.includes(sp)) {
                        this.splitor = sp;
                        break;
                    }
                }
                for (let userCookies of ckStr.split(this.splitor).filter(x => !!x)) {
                    $.cookie_list.push(new Bar(userCookies))
                }
                userCount = $.cookie_list.length
            } else {
                console.log(`\n【${NAME}】：未填写变量: ${VALY}`)
            }
            console.log(`共找到${userCount}个账号`)
            return $.cookie_list
        }

        // 运行模块 get post put delete patch head options
        task(method, taskurl, taskheader, taskbody, taskhost) {
            if (method == 'delete') {
                method = method.toUpperCase()
            } else {
                method = method
            }
            if (method == 'post') {
                delete taskheader['content-type']
                delete taskheader['Content-type']
                delete taskheader['content-Type']
                if ($.safeGet(taskbody)) {
                    taskheader['Content-Type'] = 'application/json;charset=UTF-8'
                } else {
                    taskheader['Content-Type'] = 'application/x-www-form-urlencoded'
                }
                if (taskbody) {
                    taskheader['Content-Length'] = $.lengthInUtf8Bytes(taskbody)
                }
            }
            if (method == 'get') {
                delete taskheader['content-type']
                delete taskheader['Content-type']
                delete taskheader['content-Type']
                delete taskheader['Content-Length']
            }
            taskheader['Host'] = taskurl['replace']('//', '/')['split']('/')[1]
            return new Promise(async resolve => {
                if (method.indexOf('T') < 0) {
                    var httpget = {
                        url: taskurl,
                        headers: taskheader,
                        body: taskbody,
                        //  timeout: 6000,
                        proxy: 'http://' + taskhost,
                    }
                } else {
                    var httpget = {
                        url: taskurl,
                        headers: taskheader,
                        form: JSON.parse(taskbody),
                        //timeout: 6000,
                        proxy: 'http://' + taskhost,
                    }
                }
                if (!taskhost) {
                    delete httpget['proxy']
                }
                this.request[method.toLowerCase()](httpget, (err, response, data) => {
                    try {
                        if (data) {
                            if (LOGS == 1) {
                                console.log(`================ 请求 ================`)
                                console.log(httpget)
                                console.log(`================ 返回 ================`)
                                if ($.safeGet(data)) {
                                    console.log(JSON.parse(data))
                                } else {
                                    console.log(data)
                                }
                            }
                        }
                    } catch (e) {
                        console.log(e, taskurl + '\n' + taskheader)
                    } finally {
                        let datas = ''
                        if (!err) {
                            if ($.safeGet(data)) {
                                datas = JSON.parse(data)
                            } else if (data.indexOf('/') != -1 && data.indexOf('+') != -1) {
                                datas = $.decrypts(data)
                            } else {
                                datas = data
                            }
                        } else {
                            datas = taskurl + '   API请求失败，请检查网络重试\n' + err
                        }
                        return resolve(datas)
                    }
                })
            })
        }
        task2(method, taskurl, taskheader, taskbody, taskhost) {
            if (method == 'delete') {
                method = method.toUpperCase()
            } else {
                method = method
            }
            if (method == 'post') {
                delete taskheader['content-type']
                delete taskheader['Content-type']
                delete taskheader['content-Type']
                if ($.safeGet(taskbody)) {
                    taskheader['Content-Type'] = 'application/json;charset=UTF-8'
                } else {
                    taskheader['Content-Type'] = 'application/x-www-form-urlencoded'
                }
                if (taskbody) {
                    taskheader['Content-Length'] = $.lengthInUtf8Bytes(taskbody)
                }
            }
            if (method == 'get') {
                delete taskheader['content-type']
                delete taskheader['Content-type']
                delete taskheader['content-Type']
                delete taskheader['Content-Length']
            }
            taskheader['Host'] = taskurl['replace']('//', '/')['split']('/')[1]
            if (method.indexOf('T') < 0) {
                var httpget = {
                    url: taskurl,
                    headers: taskheader,
                    body: taskbody,

                }
            } else {
                var httpget = {
                    url: taskurl,
                    headers: taskheader,
                    form: JSON.parse(taskbody),
                }
            }
            // console.log(httpget);
            return new Promise(async resolve => {
                this.request[method.toLowerCase()](httpget, (err, response, data) => {
                    try {
                        if (data) {
                            if (LOGS == 1) {
                                console.log(`================ 请求 ================`)
                                console.log(httpget)
                                console.log(`================ 返回 ================`)
                                if ($.safeGet(data)) {
                                    console.log(JSON.parse(data))
                                } else {
                                    console.log(data)
                                }
                            }
                        }
                    } catch (e) {
                        console.log(e, taskurl + '\n' + taskheader)
                    } finally {
                        let datas = ''
                        if (!err) {
                            if ($.safeGet(data)) {
                                datas = data
                            } else if (data.indexOf('/') != -1 && data.indexOf('+') != -1) {
                                datas = $.decrypts(data)
                            } else {
                                datas = data
                            }
                        } else {
                            datas = taskurl + '   API请求失败，请检查网络重试\n' + err
                        }
                        return resolve(datas)
                    }
                })
            })
        }
        //body长度
        lengthInUtf8Bytes(str) {
            let m = encodeURIComponent(str).match(/%[89ABab]/g)
            return str.length + (m ? m.length : 0)
        }
        //随机数组
        randomArr(arr) {
            return arr[parseInt(Math.random() * arr.length, 10)];
        }
        //延迟
        wait(t) {
            return new Promise(e => setTimeout(e, t))
        }
        //当前时间戳s=10位时间戳或13位时间戳
        time(s) {
            if (s == 10) {
                return Math.round(+new Date() / 1000)
            } else {
                return +new Date()
            }
        }
        //时间戳格式化日期
        timenow(str) {
            let date = new Date()
            if (str == undefined) {
                let date = new Date(),
                    N = date.getFullYear() + '-',
                    Y = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-',
                    R = date.getDate() + ' ',
                    S = date.getHours() + ':',
                    F = date.getMinutes() + ':',
                    M = date.getSeconds() + 1 < 10 ? '0' + date.getSeconds() : date.getSeconds()
                return N + Y + R + S + F + M
            } else if (str == 0) {
                //年
                return date.getFullYear()
            } else if (str == 1) {
                //月
                return date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
            } else if (str == 2) {
                //日
                return date.getDate()
            } else if (str == 3) {
                //时
                return date.getHours()
            } else if (str == 4) {
                //分
                return date.getMinutes()
            } else if (str == 5) {
                //秒
                return date.getSeconds() + 1 < 10 ? '0' + date.getSeconds() : date.getSeconds()
            }
        }
        //数据检查
        safeGet(data) {
            try {
                if (typeof JSON.parse(data) == 'object') {
                    return true
                }
            } catch (e) {
                return false
            }
        }
        //随机字符
        SJS(len, t) {
            if (t == 0) {
                let chars = 'QWERTYUIOPASDFGHJKLZXCVBNM01234567890123456789'
                let maxLen = chars.length
                let str = ''
                for (let i = 0; i < len; i++) {
                    str += chars.charAt(Math.floor(Math.random() * maxLen))
                }
                return str
            } else if (t == 1) {
                let chars = 'qwertyuiopasdfghjklzxcvbnm0123456789'
                let maxLen = chars.length
                let str = ''
                for (let i = 0; i < len; i++) {
                    str += chars.charAt(Math.floor(Math.random() * maxLen))
                }
                return str
            } else {
                let chars = '0123456789'
                let maxLen = chars.length
                let str = ''
                for (let i = 0; i < len; i++) {
                    str += chars.charAt(Math.floor(Math.random() * maxLen))
                }
                return str
            }
        }
        //随机$.udid  0=大写  1=小写
        udid(str) {
            function S4() {
                return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
            }
            let uuid = S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4()
            if (str == 0) {
                return uuid.toUpperCase()
            } else {
                return uuid.toLowerCase()
            }
        }
        //  .toUpperCase()  转化大写
        //  .toLowerCase()  转化小写
        //console.log(...new Set(arr))去重
        //KEY = [...new Set(KEY.filter(item => !!item))]
        //filter(item => !!item) 过滤1!=1
        //Array.from()方法就是将一个类数组对象或者可遍历对象转换成一个真正的数组。
        //es编码  escape("中文")
        //es解码  unescape("%u4E2D%u6587")
        //URI编码  encodeURI("中文") 不完全
        //URI解码  decodeURI("%E4%B8%AD%E6%96%87")  不完全
        //URIC编码  encodeURIComponent("中文")
        //URIC解码  decodeURIComponent("%E4%B8%AD%E6%96%87")
        //str编码
        encodeUnicode(str) {
            var res = []
            for (var i = 0; i < str.length; i++) {
                res[i] = ('00' + str.charCodeAt(i).toString(16)).slice(-4)
            }
            return '\\u' + res.join('\\u')
        }
        //str解码
        decodeUnicode(str) {
            str = str.replace(/\\u/g, '%u')
            return unescape(unescape(str))
        }
        RT(X, Y) {
            return Math.round(Math.random() * (Y - X) + X)
        }
        //去除数组空值 console.log($.arrNull(['A', '', 'B', null, undefined, 'C', '  ']))
        arrNull(arr) {
            var r = arr.filter(s => {
                return s && s.trim()
            })
            return r
        }
        //国际标准时间
        nowtime() {
            return new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000)
        }
        //日期格式化时间戳
        timecs() {
            let newtime = $.nowtime()
            if (JSON.stringify(newtime).indexOf(' ') >= 0) {
                newtime = newtime.replace(' ', 'T')
            }
            return new Date(newtime).getTime() - 8 * 60 * 60 * 1000
        }
        //键值对转json  $.rtjson(str, '&', '=',1)
        rtjson(input, apart, apart2, i) {
            if (i == 0) {
                return JSON.stringify(
                    input.split(apart).reduce((sum, item) => {
                        let temp = item.split(apart2)
                        sum[temp[0].trim()] = temp[1].trim()
                        return sum
                    }, {})
                )
            } else {
                return input.split(apart).reduce((sum, item) => {
                    let temp = item.split(apart2)
                    sum[temp[0].trim()] = temp[1].trim()
                    return sum
                }, {})
            }
        }
        //md5加密 0=32位小写,1=32位大写,2=中间16位小写,3=中间16位大写
        MD5Encrypt(i, str) {
            if (i == 0) {
                return this.CryptoJS.MD5(str).toString().toLowerCase()
            } else if (i == 1) {
                return this.CryptoJS.MD5(str).toString().toUpperCase()
            } else if (i == 2) {
                return this.CryptoJS.MD5(str).toString().substring(8, 24).toLowerCase()
            } else if (i == 3) {
                return this.CryptoJS.MD5(str).toString().substring(8, 24).toUpperCase()
            }
        }
        //SHA类：SHA1,SHA3,SHA224,SHA256,SHA384,SHA512,RIPEMD160
        //SHA类加密方式  使用：SHA_Encrypt(0, 'SHA1', str) 或 SHA_Encrypt(1,'SHA256', str)
        //0表示加密后编码，1直接使用hex格式
        SHA_Encrypt(i, Encrypt, str) {
            if (i == 0) {
                return this.CryptoJS[Encrypt](str).toString(this.CryptoJS.enc.Base64)
            } else {
                return this.CryptoJS[Encrypt](str).toString()
            }
        }
        //HmacSHA类：HmacSHA1,HmacSHA3,HmacSHA224,HmacSHA256,HmacSHA384,HmacSHA512,HmacRIPEMD160
        //0表示加密后编码，1直接使用hex格式
        //SHA类加密方式  使用：SHA_Encrypt(0,'HmacSHA1', str,key) 或 SHA_Encrypt(1,'HmacSHA256', str,key)
        HmacSHA_Encrypt(i, Encrypt, str, key) {
            if (i == 0) {
                return this.CryptoJS[Encrypt](str, key).toString(this.CryptoJS.enc.Base64)
            } else {
                return this.CryptoJS[Encrypt](str, key).toString()
            }
        }
        //Base64 0=编码 1=解码
        Base64(i, str) {
            if (i == 0) {
                return this.CryptoJS.enc.Base64.stringify(this.CryptoJS.enc.Utf8.parse(str))
            } else {
                return this.CryptoJS.enc.Utf8.stringify(this.CryptoJS.enc.Base64.parse(str))
            }
        }
        //AES/DES加解密 0=加密  1=解密
        //使用方法：DecryptCrypto(`0`,`AES`, `ECB`, `Pkcs7`, data, 'key', 'iv')
        DecryptCrypto(i, method, mode, padding, data, key, iv) {
            if (i == 0) { 
                const encrypted = this.CryptoJS[method].encrypt(this.CryptoJS.enc.Utf8.parse(data), this.CryptoJS.enc.Utf8.parse(key), {
                    iv: this.CryptoJS.enc.Utf8.parse(iv),
                    mode: this.CryptoJS.mode[mode],
                    padding: this.CryptoJS.pad[padding],
                })
                return encrypted.toString()
            } else {
                const decrypt = this.CryptoJS[method].decrypt(data, this.CryptoJS.enc.Utf8.parse(key), {
                    iv: this.CryptoJS.enc.Utf8.parse(iv),
                    mode: this.CryptoJS.mode[mode],
                    padding: this.CryptoJS.pad[padding],
                })
                return decrypt.toString(this.CryptoJS.enc.Utf8)
            }
        }
        //RSA加密
        RSA(msg, Key) {
            const NodeRSA = require('node-rsa')
            let nodersa = new NodeRSA('-----BEGIN PUBLIC KEY-----\n' + Key + '\n-----END PUBLIC KEY-----')
            nodersa.setOptions({ encryptionScheme: 'pkcs1' })
            return nodersa.encrypt(msg, 'base64', 'utf8')
        }
        SHA_RSA(str, Keys) {
            let key = this.Sha_Rsa.KEYUTIL.getKey('-----BEGIN PRIVATE KEY-----\n' + $.getNewline(Keys, 76) + '\n-----END PRIVATE KEY-----')
            let signature = new this.Sha_Rsa.KJUR.crypto.Signature({ alg: 'SHA256withRSA' })
            signature.init(key)
            signature.updateString(str)
            let originSign = signature.sign()
            let sign64u = this.Sha_Rsa.hextob64u(originSign)
            return sign64u
        }
    })()
}
//RSA加密 RSA/ECB/PKCS1Padding
async function RSA(str, Key) {
    const NodeRSA = require('node-rsa')
    let nodersa = new NodeRSA('-----BEGIN PUBLIC KEY-----\n' + Key + '\n-----END PUBLIC KEY-----')
    nodersa.setOptions({ encryptionScheme: 'pkcs1' })
    return nodersa.encrypt(str, 'base64', 'utf8')
}
async function gpt() {
    let data = await $.task('get', `https://gitee.com/xiaogangg/shishi/raw/changgu/ks.json`, { "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 13; M2012K11AC Build/TKQ1.220829.002)" })
    let ben=data[VALY]
    console.log(`脚本版本：${Vacation}   最新版本：${ben}`)
   if (Vacation != ben) {
        console.log(`发现新版本，正在更新`)
        let updatedScript = await $.task('get', `http://j.jg86.cn:5244/d/xiaogang/ddgs.js`, {})
        const fs = require('fs').promises;
			const scriptPath = process.argv[1]; // 获取当前脚本的路径
			await fs.writeFile(scriptPath, updatedScript);
			console.log(`脚本更新完成，请重新运行脚本`);
			const e = Date.now();
			await done(s, e);
			process.exit()
        
    }
}
